<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/view/console/common/css.html"){}	%>

 <title></title>
 </head>
 <body>
 <div class="zq-form">
  <blockquote class="layui-elem-quote">双击关联数据</blockquote>
 <form  class="form-horizontal" style="margin-bottom: 70px;">
  <div class="form-group">
   <label class="col-sm-2 col-xs-2 control-label">机具列表</label>
   <div class="col-sm-10 col-xs-10">
     <table id="wnMachineTool" data-toggle="table"
            data-url="${ctxPath}/console/wn_machine_link/tool/json"
            data-pagination="true"
            data-query-params="wnMachineToolLoadParam"
            method="post"
            data-side-pagination="server"
            data-show-refresh="true"
            data-show-toggle="true"
            data-pagination-loop="false"
            data-show-columns="true"
            data-toolbar="#wnMachineToolToolbar">
      <thead>
      <tr>
       <th data-checkbox="true"></th>
       <th data-field='id' data-visible='false'>ID</th>
       <th data-sortable='false' data-field='name'>机具名称</th>
       <th data-sortable='false' data-field='toolNumber'>机具编码</th>
       <th data-sortable='false' data-field='buyTime'  data-formatter="consoleTableDateFormat">购入时间</th>
       <th data-sortable='false' data-field='brand'>品牌</th>
       <th data-sortable='false' data-field='breadth'>幅宽</th>
       <th data-sortable='false' data-field='type'>机具类型</th>
       <th data-sortable='false' data-field='farmName'>所属农场</th>
      </tr>
      </thead>
     </table>
   </div>
  </div>
  <div class="form-group" >
  <label class="col-sm-2 col-xs-2 control-label">gt06设备列表</label>
  <div class="col-sm-10 col-xs-10">
     <table id="wnMachineDeviceImei" data-toggle="table"
            data-url="${ctxPath}/console/wn_machine_link/gt06/json"
            data-pagination="true"
            data-query-params="wnMachineDeviceImeiLoadParam"
            method="post"
            data-side-pagination="server"
            data-show-refresh="true"
            data-show-toggle="true"
            data-pagination-loop="false"
            data-show-columns="true"
            data-toolbar="#wnMachineDeviceImeiToolbar">
      <thead>
      <tr>
       <th data-checkbox="true"></th>
       <th data-field='id' data-visible='false'>ID</th>
       <th data-sortable='false' data-field='deviceNumber'>设备号</th>
       <th data-sortable='false' data-field='deviceType'>设备类型</th>
       <th data-sortable='false' data-field='farmName'>所属农场</th>
       <th data-sortable='false' data-field='buyTime' data-formatter="consoleTableDateFormat">购入时间</th>
       <th data-sortable='false' data-field='imei'>imei</th>
       <th data-sortable='false' data-field='simcard'>simcard</th>
       <th data-sortable='false' data-field='validityPeriod'  data-formatter="consoleTableDateFormat">有效期</th>

      </tr>
      </thead>
     </table>
  </div>
 </div>
  <div class="form-group" >
   <label class="col-sm-2 col-xs-2 control-label">自动驾驶列表</label>
   <div class="col-sm-10 col-xs-10">
      <table id="wnMachineDevice" data-toggle="table"
             data-url="${ctxPath}/console/wn_machine_link/auto/json"
             data-pagination="true"
             data-query-params="wnMachineDeviceLoadParam"
             method="post"
             data-side-pagination="server"
             data-show-refresh="true"
             data-show-toggle="true"
             data-pagination-loop="false"
             data-show-columns="true"
             data-toolbar="#wnMachineDeviceToolbar">
       <thead>
       <tr>
        <th data-checkbox="true"></th>
        <th data-field='id' data-visible='false'>ID</th>
        <th data-sortable='false' data-field='deviceNumber'>设备号</th>
        <th data-sortable='false' data-field='deviceType'>设备类型</th>
        <th data-sortable='false' data-field='farmName'>所属农场</th>
       </tr>
       </thead>
      </table>
   </div>
  </div>
  <input id="farmId" type="hidden" value="${machine.farmId!}">
  <input id="id" type="hidden" value="">
 </form>
 </div>
 <% include("/view/console/common/js.html"){} 	%>
 <script type='text/javascript' src='/view/console/wnMachineDevice/wnMachineDeviceTableLink.js'></script>
 <script type='text/javascript' src='/view/console/wnMachineDeviceImei/wnMachineDeviceImeiTableLink.js'></script>
 <script type='text/javascript' src='/view/console/wnMachineTool/wnMachineToolTableLink.js'></script>
 <script>
  $(function () {


     $('#wnMachineDevice').on('dbl-click-row.bs.table', function (row, element, field) {
         var machineId = "${machine.machineId}";
         var deviceId = element.id;
         var deviceType = element.deviceType;
         var req = {
             machineId:machineId,
             deviceId:deviceId,
             deviceType:deviceType
         }
         zqPost("/console/wn_machine_link/auto/link",req,function (data) {
             layui.layer.alert("关联成功!");
             parent.$("#wnMachineDevice").bootstrapTable("refresh");
         });
         console.log(element);

     });
     $('#wnMachineTool').on('dbl-click-row.bs.table', function (row, element, field) {
         var machineId = "${machine.machineId}";
         var toolId = element.id;
         var req = {
             machineId:machineId,
             toolId:toolId
         }
         zqPost("/console/wn_machine_link/tool/link",req,function (data) {
             layui.layer.alert("关联成功!");
             parent.$("#wnMachineTool").bootstrapTable("refresh");
         });
         console.log(element);
     });
     $('#wnMachineDeviceImei').on('dbl-click-row.bs.table', function (row, element, field) {
         var machineId = "${machine.machineId}";
         var deviceId = element.id;
         var deviceType = element.deviceType;
         var req = {
             machineId:machineId,
             deviceId:deviceId,
             deviceType:deviceType
         }
         zqPost("/console/wn_machine_link/gt06/link",req,function (data) {
             layui.layer.alert("关联成功!");
             parent.$("#wnMachineDeviceImei").bootstrapTable("refresh");
         });
         console.log(element);
     });
  });
 </script>
 </body>
